<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>我的订单</title>
    <link rel="stylesheet" href="../../css/base.css">
    <link rel="stylesheet" href="../../css/personal/myorder.css">
    <link rel="stylesheet" href="../../css/tixian.css">
    <script src="../../js/jquery-2.2.3.min.js"></script>
    <script src="../../js/rem.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../detail/js/vue.min.js"></script>
    <script src="../detail/js/vue-resource.min.js"></script>
    <link rel="stylesheet" href="../../css/zhifu.css">
    <style>
        .cont-name2 p {
            display: inline-block !important;
            float: left;
        }

        .cont-logo img {
            width: 100%;
            float: left;
        }

        .f-s-btn {
            margin: 0 0.05rem;
        }

        .apply-goods {
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            position: fixed;
            z-index: 10000;
        }

        .applyContainer {
            height: 1.9rem;
            width: 3rem;
            background: #ffffff;
            margin: 0 auto;
            position: absolute;
            top: 50%;
            margin-top: -0.95rem;
            left: 50%;
            margin-left: -1.5rem;
            border-radius: 0.1rem;
        }

        .apply-number {
            height: 0.5rem;
            line-height: 0.5rem;
            color: #8E8E93;
            font-size: 0.14rem;
            text-align: right;
            padding: 0 0.2rem;
        }

        .apply-num {
            background-color: #ffffff;
            /* line-height: 0.5rem; */
            width: 0.5rem;
            color: #8E8E93;
            border: none;
            outline: none;
            /* border-bottom: 1px solid #000000; */
            text-align: right;
            margin: 0 0.05rem;
        }

        .canapply {
            width: 90%;
            margin: 0.2rem auto;
        }

        .apply-ul {
            width: 90%;
            margin: 0.1rem auto;
            position: relative;
            overflow: hidden;
        }

        .apply-ul li {
            text-align: center;
            width: 50%;
            float: left;
            height: 0.3rem;
            line-height: 0.3rem;
        }

        .apply-line {
            display: block;
            left: 50%;
            margin-left: -0.5px;
            background: #ccc;
            width: 1px;
            top: 50%;
            margin-top: -0.1rem;
            height: 0.2rem;
            position: absolute;
        }
        /*******************/
        .footerMask{
            position: fixed;
            display: none;
            left: 0;
            bottom: 0;
            width: 100%;
            background-color: #fff;
        }
        .footerMask li{
            height: .5rem;
            line-height: .5rem;
            padding: 0 .05rem;
            border-bottom: 1px solid #ccc;
        }
        .footerMaskT img{
            width: .34rem;
            height: .34rem;
            display: inline-block;
            margin-right: .05rem;
        }
        .let1{
            width: .34rem;
            height: .34rem;
            display: inline-block;
            margin-right: .05rem;
        }
        .to{
            float: right;
            width: .24rem;
            height: .24rem;
            margin-top: .12rem;
            display: none;
        }
        .active .to{
            display: block;
        }
        .choiceCard{
            font-size: .20rem;
            text-align: center;
            height: .5rem;
            line-height: .5rem;
            border-bottom: 1px solid #ccc;
            border-top: 1px solid #ccc;
        }
        .choiceCard i{
            float: right;
            margin-right: 0.15rem;
        }

        .btn_zf{
            font-size: .16rem;
            padding: 0 .15rem;
            margin-top: .1rem;

        }
        .btn_zf span{
            display: block;
            text-align: center;
            height: .5rem;
            line-height: .5rem;
            background-color: #e73e40;
            border-radius: 0.05rem;
            color: #fff;
        }
        .verification input{
            font-size: .14rem;
            width: 40%;
        }
        .verification{
            font-size: .16rem;
        }
        .verification span{
            float: right;
            width: 0.96rem;
            font-size: 0.12rem;
            height: 0.32rem;
            background: #F59394;
            color: #ffffff;
            text-align: center;
            border-radius: 0.05rem;
            line-height: 0.32rem;
            margin-top: 0.08rem;
        }
    </style>
</head>

<body style="background-color: #F5F5F5">
    <div class="apply-goods" style="display:none;">
        <div class="applyContainer">
            <p class="apply-number">请输入要库存数<input style="background: #ffffff;" class="apply-num" type="text">件</p>
            <div class="apply-num-con">

            </div>
            <ul class="apply-ul">
                <li class="apply-dis">取消</li>
                <span class="apply-line"></span>
                <li class="apply-shure" style="color: #EB4748;"></li>
            </ul>
        </div>
    </div>
    <div id="app">
        <div class="head" style="z-index:1002;">
            <div class="h-left" onclick="javascript:location.href='index.html'"></div>
            <div class="h-middle">我的订单</div>
            <div class="h-right"></div>
        </div>
        <div style="height: .44rem;"></div>
        <ul class="navBox" style="overflow-x:auto;">
            <li class="nav-item navActive" data-index="0">全部</li>
            <li class="nav-item nav-itemWait" data-index="1">待付款</li>
            <li class="nav-item nav-itemFa" data-index="2">已付款</li>
            <li class="nav-item nav-itemRec" data-index="3">待收货</li>
            <li class="nav-item nav-itemOk" data-index="4">已完成</li>
        </ul>
        <div class="contBox">
            <!--全部-->
            <div class="cont-item cont-item-all">

            </div>
            <!-- 代付款 -->
            <div class="cont-item cont-item-wait">

            </div>
            <!-- 代发货 -->
            <div class="cont-item cont-item-fa">

            </div>
            <!-- 待收货 -->
            <div class="cont-item cont-item-rec">

            </div>
            <!-- 已完成 -->
            <div class="cont-item cont-item-ok">

            </div>
        </div>
        <!--浮动层-->
        <!--<div class="ftc_wzsf">-->
            <!--<div class="srzfmm_box">-->
                <!--<div class="qsrzfmm_bt clear_wl">-->
                    <!--<img src="../../img/xx_03.jpg" class="tx close fl">-->
                    <!--<span class="fl">请输入支付密码</span></div>-->
                <!--<div class="zfmmxx_shop">-->
                    <!--<div class="mz"></div>-->
                    <!--<div class="zhifu_price"></div>-->
                <!--</div>-->
                <!--<ul class="mm_box">-->
                    <!--<li></li>-->
                    <!--<li></li>-->
                    <!--<li></li>-->
                    <!--<li></li>-->
                    <!--<li></li>-->
                    <!--<li></li>-->
                <!--</ul>-->
            <!--</div>-->
            <!--<div class="numb_box">-->
                <!--<div class="xiaq_tb" style="height: 0.2rem;clear: both;">-->
                    <!--<img src="../../img/jftc_14.jpg" style="height: 0.1rem;float: left;margin-left: 46%;">-->
                <!--</div>-->
                <!--<ul class="nub_ggg">-->
                    <!--<li><a href="javascript:void(0);" class="zf_num">1</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zj_x zf_num">2</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zf_num">3</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zf_num">4</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zj_x zf_num">5</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zf_num">6</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zf_num">7</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zj_x zf_num">8</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zf_num">9</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zf_empty">清空</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zj_x zf_num">0</a></li>-->
                    <!--<li><a href="javascript:void(0);" class="zf_del">删除</a></li>-->
                <!--</ul>-->
            <!--</div>-->
            <!--<div class="hbbj"></div>-->
        <!--</div>-->

        <div class="footerMask">
            <div class="choiceCard">
                选择支付方式
                <i @click="close" class="close">X</i>
            </div>
            <ul class="footerMaskO" >
            <!--<li class="active">-->
                <!--<img class="let1" src="../../img/g_tixian_afb.png" alt="" >-->
                <!--<span>支付宝</span>-->
                <!--<img class="to" src="../../img/icon-true.png" alt="">-->
            <!--</li>-->
            <!--<li>-->
            <!--<img class="let1"  src="../img/g_tixian_wx.png" alt="">-->
            <!--<span>微信</span>-->
            <!--<img class="to" src="../img/icon-true.png" alt="">-->
            <!--</li>-->
        </ul>
            <ul class="footerMaskO">
                <li class="" :class="currentTab == 0 ?'active':''" @click="footerMaskIte(0,0)">
                    <img class="let1" src="../../img/g_tixian_afb.png" alt="" >
                    <span>支付宝</span>
                    <img class="to" src="../../img/icon-true.png" alt="">
                </li>
                <li :class="currentTab == -1 ?'active':''" @click="footerMaskIte(-1,-1)">
					<img class="let1" src="../../img/g_tixian_wx.png" alt="" >
					<span>微信</span>
					<img class="to" src="../../img/icon-true.png" alt="">
				</li>
            </ul>
            <ul>
                <li @click="btn_zf" class="btn_zf">
                    <span>提交</span>
                </li>
            </ul>
        </div>


    </div>

    <script>
        var app = new Vue({
            el:'#app',
            data:{
                BankList:[],
                currentTab:99,
                bankCardId:''
            },
            mounted:function(){
                // let _this = this
                // this.$http.post(SURL + '/jfd/usersBankcards/selectUsersBankcards',{userId:localStorage.getItem('userId')} , {emulateJSON: true}).then(res => {
                //     console.log(res.data.data);
                //     _this.BankList = res.data.data
                // })
                // console.log(_this.BankList);
            },
            methods:{
                // close: function () {
                //     $(".footerMask").hide();
                //     $(".mm_box li").removeClass("mmdd");
                //     $(".mm_box li").attr("data", "");
                //     i = 0;
                // },
                addBank(){
                    location.href = '../aad/addBankCard.html'
                },
                footerMaskIte(index,id){
                    console.log(index);
                    console.log(id);
                    this.bankCardId = id
                    this.currentTab = index
                },
                btn_zf: function () {
                	
                	if(this.bankCardId==-1){
            		var obj = {
	                        orderunique: localStorage.getItem('orderunique'),
	                        payType:'1',
	                        bankCardId: this.bankCardId,
	                        userId: localStorage.getItem('userId'),
                		}
	                }else if(this.bankCardId==0){
	                	var obj = {
	                        orderunique: localStorage.getItem('orderunique'),
	                        payType:'2',
	                        bankCardId: this.bankCardId,
	                        userId: localStorage.getItem('userId'),
	                	}
					}else {
	                    var obj = {
	                        orderunique: localStorage.getItem('orderunique'),
	                        payType:'3',
	                        bankCardId: this.bankCardId,
	                        userId: localStorage.getItem('userId'),
	                    }
					}
//                  let obj = {
//                      orderunique: localStorage.getItem('orderunique'),
//                      payType:'2',
//                      bankCardId: this.bankCardId,
//                      userId: localStorage.getItem('userId'),
//                  }
                    localStorage.setItem('bankCardId',this.bankCardId)
                    console.log(this.bankCardId);
                    // var cc = this.bankCardId
                    // if(cc){
                        this.$http.post(SURL + '/api/xlsshoporders/thirdPayApply',obj , {emulateJSON: true}).then(res => {
                            console.log(res);
							if (res.body.status == 1){
								if(res.body.data.payType==2){
								    localStorage.setItem('data',res.body.data.orderString)
								    if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
								        window.location.href = "iospay" + "," +res.body.data.orderString;
								    } else if (/(Android)/i.test(navigator.userAgent)) {
								        window.android.aliPay(res.body.data.orderString)
								    }
								    // window.location.href='./payCode.html'
								}else if(res.body.data.payType==1){
									localStorage.setItem('data',res.body.data.orderString)
								    if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
										var iosJson=JSON.stringify(res.body.data.orderString);
								        window.location.href = "ioswxpay" + "|" +iosJson;
								    } else if (/(Android)/i.test(navigator.userAgent)) {
								    	var sign = res.body.data.orderString.sign;
								    	var noncestr = res.body.data.orderString.nonce_str;
								    	var packageX = res.body.data.orderString.package;
								    	var appid = res.body.data.orderString.appid;
								    	var prepayid = res.body.data.orderString.prepay_id;
								    	var partnerid = res.body.data.orderString.mch_id;
								    	var timestamp = res.body.data.orderString.timestamp;
								        window.android.wxPay(appid,noncestr,packageX,partnerid,prepayid,sign,timestamp)
								    }
								}else {
								    alert(res.body.msg)
								}
							}else{
								alert(res.body.msg)
							}
	                            
                        })


                    // }else {
                    //     alert('请选择银行')
                    // }

                },
            }
        })

        function payResult() {
            location.href = 'personal/myorder.html?ling=2'
        }
        function GetRequest() {
            //获取url中"?"符后的字串 
            var url = location.search;
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }
        var theRequest = GetRequest();
        $(document).ready(function () {
            $(".navBox li").mouseover(function () {
                //通过 .index()方法获取元素下标，从0开始，赋值给某个变量
                var _index = $(this).index();
                //让内容框的第 _index 个显示出来，其他的被隐藏
                $(".contBox>div").eq(_index).show().siblings().hide();
                //改变选中时候的选项框的样式，移除其他几个选项的样式
                $(this).addClass("navActive").siblings().removeClass("navActive");
            });
        });
        // console.log()
        let data = {
            userId: localStorage.getItem('userId'),
            pageNum: 1
        }
        $.ajax({
            url: SURL + '/api/xlsshoporders/getAllOrderData',
            data: data,
            // dataType: 'json',
            type: 'POST',
            success: res => {
                // 全部订单
                var order = res.data.data
                var orders1 = order.filter(ele => ele.orderType != 3)
                //orders数组
                orders1.forEach(currentAll => {
                    currentAll.shopOrdersList.forEach(element => {
                        var allDiv =
                            `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2"></div>
                                    </div>
                                `
                        allDiv +=
                            `
                            <div class="c-i-middle" data-id="${element.id}" onclick="orderDetail(this)">
                                <img src="${ImageUrl + element.goodsImg}" class="i-yanjing" alt="">
                                <div class="middle-name">${element.goodsName}</div>
                                <div class="middle-money">￥${element.goodsMoney}</div>
                                <div class="middle-money2"> <u>￥${element.goodsMoney}</u> </div>
                                <div class="middle-num">×1</div>
                            </div>
                            `
                        allDiv +=
                            `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                        </div>
                        `
                        $('.cont-item-all').append(allDiv)
                    });
                });
                // 代付款订单
                $('.nav-itemWait').click(() => {
                    $('.cont-item-wait').text('');
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf
                            .orderStatus ==
                            -2)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">待付款</div>
                                    </div>
                                `
                            allDiv +=
                                `
                            <div class="c-i-middle" data-id="${element.id}" onclick="orderDetail(this)">
                                <img src="${ImageUrl + element.goodsImg}" class="i-yanjing" alt="">
                                <div class="middle-name">${element.goodsName}</div>
                                <div class="middle-money">￥${element.goodsMoney}</div>
                                <div class="middle-money2"> <u>￥${element.goodsMoney}</u> </div>
                                <div class="middle-num">×1</div>
                            </div>
                            `
                            allDiv +=
                                `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                             <div class="cont-submit redBtn" data-un="${element.orderunique}" onclick="subPay(this)" >去支付</div>
                             <div class="cont-submit qxBtn" onclick="deleteOrder(this)" data-id="${element.id}">取消订单</div>
                        </div>
                        `
                            $('.cont-item-wait').append(allDiv)
                        });
                    });
                });
                // 已付款
                $('.nav-itemFa').click(() => {
                    $('.cont-item-fa').text('');
                    console.log(orders1)
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf
                            .orderStatus ==
                            0)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">已付款</div>
                                    </div>
                                `
                            allDiv +=
                                `
                            <div class="c-i-middle" data-id="${element.id}" onclick="orderDetail(this)">
                                <img src="${ImageUrl + element.goodsImg}" class="i-yanjing" alt="">
                                <div class="middle-name">${element.goodsName}</div>
                                <div class="middle-money">￥${element.goodsMoney}</div>
                                <div class="middle-money2"> <u>￥${element.goodsMoney}</u> </div>
                                <div class="middle-num">×$1</div>
                            </div>
                            `
                            allDiv +=
                                `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                        </div>
                        `
                            $('.cont-item-fa').append(allDiv)
                        });
                    });
                })

                //待收货
                $('.nav-itemRec').click(() => {
                    $('.cont-item-rec').text('');
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf
                            .orderStatus ==
                            1)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">待收货</div>
                                    </div>
                                `
                            allDiv +=
                                `
                            <div class="c-i-middle" data-id="${element.id}" onclick="orderDetail(this)">
                                <img src="${ImageUrl + element.goodsImg}" class="i-yanjing" alt="">
                                <div class="middle-name">${element.goodsName}</div>
                                <div class="middle-money">￥${element.goodsMoney}</div>
                                <div class="middle-money2"> <u>￥${element.goodsMoney}</u> </div>
                                <div class="middle-num">×$1</div>
                            </div>
                            `
                            allDiv +=
                                `
                                <div class="c-i-bottom">
                                    共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                                </div>
                            </div>
                        `
                            $('.cont-item-rec').append(allDiv)
                        });
                    });
                })
                //已完成
                $('.nav-itemOk').click(() => {
                    $('.cont-item-ok').text('');
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf
                            .orderStatus ==
                            5)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">已完成</div>
                                    </div>
                                `
                            allDiv +=
                                `
                            <div class="c-i-middle" data-id="${element.id}" onclick="orderDetail(this)">
                                <img src="${ImageUrl + element.goodsImg}" class="i-yanjing" alt="">
                                <div class="middle-name">${element.goodsName}</div>
                                <div class="middle-money">￥${element.goodsMoney}</div>
                                <div class="middle-money2"> <u>￥${element.goodsMoney}</u> </div>
                                <div class="middle-num">×$1</div>
                            </div>
                            `
                            allDiv +=
                                `
                                <div class="c-i-bottom">
                                    共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                                </div>
                            </div>
                        `
                            $('.cont-item-ok').append(allDiv)
                        });
                    });
                })
            }
        })
        if (theRequest.ling == 1) { //代付款
            $('.nav-itemWait').addClass('navActive')
            $('.nav-itemWait').siblings().removeClass('navActive')
            $('.cont-item-wait').show();
            $('.cont-item-wait').siblings().hide();
            $.ajax({
                url: SURL + '/api/xlsshoporders/getAllOrderData',
                data: data,
                // dataType: 'json',
                type: 'POST',
                success: res => {
                    var order = res.data.data
                    var orders1 = order.filter(ele => ele.orderType != 3)
                    $('.cont-item-wait').text('');
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            -2)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont cont-item-pay">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">待付款</div>
                                    </div>
                                `
                            allDiv +=
                                `
                            <div class="c-i-middle" data-id="${element.id}" onclick="orderDetail(this)">
                                <img src="${ImageUrl + element.goodsImg}" class="i-yanjing" alt="">
                                <div class="middle-name">${element.goodsName}</div>
                                <div class="middle-money">￥${element.goodsMoney}</div>
                                <div class="middle-money2"> <u>￥${element.goodsMoney}</u> </div>
                                <div class="middle-num">×$1</div>
                            </div>
                            `
                            allDiv +=
                                `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                            <div class="cont-submit redBtn" data-un="${element.orderunique}" onclick="subPay(this)" >去支付</div>
                            <div class="cont-submit qxBtn" onclick="deleteOrder(this)" data-id="${element.id}">取消订单</div>
                        </div>
                        `
                            $('.cont-item-wait').append(allDiv)
                        });
                    });
                }
            })

        } else if (theRequest.ling == 2) { //已付款
            $('.nav-itemFa').addClass('navActive')
            $('.nav-itemFa').siblings().removeClass('navActive')
            $('.cont-item-fa').show();
            $('.cont-item-fa').siblings().hide();
            $('.cont-item-fa').html('');
            $.ajax({
                url: SURL + '/api/xlsshoporders/getAllOrderData',
                data: data,
                // dataType: 'json',
                type: 'POST',
                success: res => {
                    var order = res.data.data
                    var orders1 = order.filter(ele => ele.orderType != 3)
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            0)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">已付款</div>
                                    </div>
                                `
                            allDiv +=
                                `
                            <div class="c-i-middle" data-id="${element.id}" onclick="orderDetail(this)">
                                <img src="${ImageUrl + element.goodsImg}" class="i-yanjing" alt="">
                                <div class="middle-name">${element.goodsName}</div>
                                <div class="middle-money">￥${element.goodsMoney}</div>
                                <div class="middle-money2"> <u>￥${element.goodsMoney}</u> </div>
                                <div class="middle-num">×$1</div>
                            </div>
                            `
                            allDiv +=
                                `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>

                        `
                            $('.cont-item-fa').append(allDiv)
                        });
                    });
                }
            })

        } else if (theRequest.ling == 3) { //待发货
            $('.nav-itemRec').addClass('navActive')
            $('.nav-itemRec').siblings().removeClass('navActive')
            $('.cont-item-rec').show();
            $('.cont-item-rec').siblings().hide();
            // $('.cont-item-rec').text('');
            $.ajax({
                url: SURL + '/api/xlsshoporders/getAllOrderData',
                data: data,
                // dataType: 'json',
                type: 'POST',
                success: res => {
                    var order = res.data.data
                    var orders1 = order.filter(ele => ele.orderType != 3)
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            1)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">待收货</div>
                                    </div>
                                `
                            allDiv +=
                                `
                            <div class="c-i-middle" data-id="${element.id}" onclick="orderDetail(this)">
                                <img src="${ImageUrl + element.goodsImg}" class="i-yanjing" alt="">
                                <div class="middle-name">${element.goodsName}</div>
                                <div class="middle-money">￥${element.goodsMoney}</div>
                                <div class="middle-money2"> <u>￥${element.goodsMoney}</u> </div>
                                <div class="middle-num">×$1</div>
                            </div>
                            `
                            allDiv +=
                                `
                                <div class="c-i-bottom">
                                    共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                                </div>
                            </div>
                        `
                            $('.cont-item-rec').append(allDiv)
                        });
                    });
                }
            })

        }
        // 取消订单
        function deleteOrder(e) {
            var orderId = $(e).attr('data-id');
            $.ajax({
                url: SURL + '/api/xlsshoporders/updateOrderStatus',
                data: {
                    id: orderId,
                    orderStatus: -1
                },
                type: 'get',
                dataType: 'json',
                success: res => {
                    // res.code==1?
                    // console.log(res);
                    if (res.status == 1) {
                        alert("取消订单成功");
                        window.location.reload();
                    }
                }
            })
        }
        // 查看详情点击
        function lookDetail(e) {
            var orderId = $(e).attr('data-id');
            //window.location.href = "order-dfk.html?orderId=" + orderId;
        }

        function orderDetail(e) {
            var orderId = $(e).attr('data-id');
            //window.location.href = "order-dfk.html?orderId=" + orderId;
        }


        // 支付
        $(function () {
            $('.tixian_password .gb').click(function () {
                $('.overlay').hide();
                $('.contBox').show();
                $('.tixian_password').hide();
            })
        })

        function subPay(e) {
            $('.footerMask').css({display: 'block'})
            var text = $(e).parents('.cont').find('.middle-name').text();
            var money = $(e).parents('.cont').find('.bottom-money').text();
            $('.mz').text(text)
            $('.zhifu_price').text('￥' + money);
            $('.cont-item-pay').attr('data-index', '');
            var uniqueCon = $(e).attr('data-un');
            // $('.overlay').show();
            // $('.contBox').hide();
            $('.ftc_wzsf').show();
            $('.ftc_wzsf').attr('data-un', uniqueCon)
            var contIndex = $(e).parent('.cont').index();
            $('.ftc_wzsf').attr('data-index', contIndex)

            app.$http.post(SURL + '/jfd/usersBankcards/selectUsersBankcards',{userId:localStorage.getItem('userId')} , {emulateJSON: true}).then(res => {
                console.log(res.data.data);
                app.BankList = res.data.data
            })
            console.log(app.BankList);



        }
        // 申请提货
        function pickGoods(e) {
            $('.apply-shure').text('提货')
            $('.apply-num-con').html('');
            $('.apply-goods').show();
            $('.apply-shure').unbind('click');
            // alert(Math.ceil(23*0.4));
            var dataId = $(e).attr('data-id');
            // $('.apply-shure').click(()=>{
            $.ajax({
                url: SURL + '/jfd/shopOrders/toApplyGoods',
                data: {
                    type: 1,
                    orderId: dataId
                },
                type: 'post',
                dataType: 'json',
                success: res => {
                    console.log(res);
                    $('.apply-num-con').append(
                        `
                        <p style="width: 90%;margin: 0.1rem auto 0.1rem auto;height:1px;background:#E3E3E3;"></p>
                        <p class="canapply">您当前商品总件数为${res.data[0].goodsNum}件，可提货件数不得大于${res.data[0].maxSendNum}件也不能小于${res.data[0].minSendNum}件。</p>
                        <p style="width: 100%;margin: 0.1rem auto 0.1rem auto;height:1px;background:#E3E3E3;"></p>
                        `
                    )
                    $('.apply-shure').unbind('click').on("click", () => {
                        var applyNum = parseInt($('.apply-num').val());
                        console.log(applyNum)
                        if (applyNum > res.data[0].maxSendNum) {
                            alert('最大不能超过' + res.data[0].maxSendNum + '件')
                        } else if (applyNum < res.data[0].minSendNum) {
                            alert('最少不能少于' + res.data[0].minSendNum + '件');
                        } else {
                            var arr = [];
                            var ordersGoods = res.data[0].ordersGoodsId;
                            paramStrObj = {
                                ordersGoodsId: ordersGoods,
                                applyNum: applyNum
                            }
                            arr.push(paramStrObj);
                            var arr1 = JSON.stringify(arr)
                            var data = {
                                type: 1,
                                paramStr: arr1,
                                userId: localStorage.getItem('userId')
                            }
                            console.log(data)
                            $.ajax({
                                url: SURL + '/jfd/shopOrders/applyGoods',
                                data: data,
                                type: 'post',
                                dataType: 'json',
                                traditional: true,
                                success: res => {
                                    console.log(res);
                                    alert(res.msg)
                                    $('.apply-goods').hide();
                                    window.location.reload();
                                }
                            })
                        }
                    })
                }
                // })
            })
        }
        // 申请库存
        function Inventory(e) {
            $('.apply-num-con').html('');
            $('.apply-shure').text('放入库存')
            $('.apply-goods').show();
            // alert(Math.ceil(23*0.4));
            var dataId = $(e).attr('data-id');
            // $('.apply-shure').click(()=>{
            $.ajax({
                url: SURL + '/jfd/shopOrders/toApplyGoods',
                data: {
                    type: 2,
                    orderId: dataId
                },
                type: 'post',
                dataType: 'json',
                success: res => {
                    console.log(res);
                    $('.apply-num-con').append(
                        `
                        <p style="width: 90%;margin: 0.1rem auto 0.1rem auto;height:1px;background:#E3E3E3;"></p>
                        <p class="canapply">您当前商品总件数为${res.data[0].goodsNum}件，可放入库存件数不得大于${res.data[0].maxStockNum-res.data[0].minStockNum}件也不能小于0件。</p>
                        <p style="width: 100%;margin: 0.1rem auto 0.1rem auto;height:1px;background:#E3E3E3;"></p>
                        `
                    )
                    $('.apply-shure').unbind('click').on("click", () => {
                        var applyNum = $('.apply-num').val();
                        if (applyNum > res.data[0].maxStockNum) {
                            alert('最大不能超过' + res.data[0].maxStockNum + '件')
                        } else if (applyNum < res.data[0].minStockNum) {
                            alert('最少不能少于' + res.data[0].minStockNum + '件')
                        } else {
                            var arr = [];
                            var ordersGoods = res.data[0].ordersGoodsId;
                            paramStrObj = {
                                ordersGoodsId: ordersGoods,
                                applyNum: applyNum
                            }
                            arr.push(paramStrObj);
                            var arr1 = JSON.stringify(arr)
                            var data = {
                                type: 2,
                                paramStr: arr1,
                                userId: localStorage.getItem('userId')
                            }
                            console.log(applyNum)
                            $.ajax({
                                url: SURL + '/jfd/shopOrders/applyGoods',
                                data: data,
                                type: 'post',
                                dataType: 'json',
                                traditional: true,
                                success: res => {
                                    console.log(res)
                                    alert(res.msg)
                                    $('.apply-goods').hide();
                                    window.location.reload();
                                }
                            })
                        }
                    })
                }
                // })
            })
        }
        $('.apply-dis').click(() => {
            $('.apply-goods').hide();
        })
    </script>
    <script>
        $(function () {
            // //出现浮动层
            // $(".TJ_btn").click(function () {
            //     $(".ftc_wzsf").show();
            // });
            //关闭浮动
            $(".close").click(function () {
                $(".footerMask").hide();
                $(".mm_box li").removeClass("mmdd");
                $(".mm_box li").attr("data", "");
                i = 0;
            });
            //数字显示隐藏
            $(".xiaq_tb").click(function () {
                $(".numb_box").slideUp(500);
            });
            $(".mm_box").click(function () {
                $(".numb_box").slideDown(500);
            });
            //----
            var i = 0;
            $(".nub_ggg li .zf_num").click(function () {
                if (i < 6) {
                    $(".mm_box li").eq(i).addClass("mmdd");
                    $(".mm_box li").eq(i).attr("data", $(this).text());
                    i++
                    if (i == 6) {
                        //   setTimeout(function(){
                        var data = "";
                        var order = $('.ftc_wzsf').attr('data-index');
                        var orderun = $('.ftc_wzsf').attr('data-un');
                        console.log(order)
                        console.log(orderun)
                        $(".mm_box li").each(function () {
                            data += $(this).attr("data");
                        });

                        console.log(data);
                        $.ajax({
                            url: SURL + '/jfd/shopOrders/payOrders',
                            data: {
                                orderunique: orderun,
                                userId: localStorage.getItem('userId'),
                                paypassword: data,
                                orderRemarks: '',
                            },
                            type: 'post',
                            traditional: 'true',
                            dataType: 'json',
                            success: res => {
                                // console.log(res)
                                alert(res.msg);
                                window.location.reload()
                                // if (res.code == 0) {
                                //     window.location.reload()
                                // }else{
                                //     window.location.reload()
                                // }
                            }
                        })
                    };
                }
            });
            $(".nub_ggg li .zf_del").click(function () {
                if (i > 0) {
                    i--
                    $(".mm_box li").eq(i).removeClass("mmdd");
                    $(".mm_box li").eq(i).attr("data", "");
                }
            });
            $(".nub_ggg li .zf_empty").click(function () {
                $(".mm_box li").removeClass("mmdd");
                $(".mm_box li").attr("data", "");
                i = 0;
            });
        })
    </script>
</body>


</html>